<?php
namespace app\controller\admin;

use app\services\admin\ChartService;
use think\App;

class Dashboard extends Application
{
    public function __construct(App $app = null)
    {
        parent::__construct($app);
    }

    public function index(ChartService $chartService)
    {
        $bar = [
            '2018-07' => mt_rand(100,1000),
            '2018-08' => mt_rand(300, 1000),
            '2018-09' => mt_rand(500, 1000),
            '2018-10' => mt_rand(700, 1000),
            '2018-11' => mt_rand(900, 1000),
            '2018-12' => mt_rand(400, 1000),
        ];

        return view('admin/dashboard/index', ['meta' => [
            'total' => $chartService->barChart($bar),
            'cdn' => $chartService->lineChart($bar, ['fill' => true]),
            'area' => $chartService->polarAreaChart($bar),
        ]]);
    }
}
